package com.linhngua.code.processing.graph;

public class Util {

	//transform from math coordinates to Graphics coordinates
	static final GraphPoint toGraphPoint(MathPoint p){
		GraphPoint point=new GraphPoint();
		point.x=p.x+Constants.WINDOW_WIDTH/2;
		point.y=-p.y+Constants.WINDOW_HEIGHT/2-50;
		return point;
	}
	
	//scale y
	static final GraphPoint toGraphPoint(MathPoint p,float scaleX,float scaleY){
		GraphPoint point=new GraphPoint();
		point.x=p.x/scaleX+Constants.WINDOW_WIDTH/2;
		point.y=-p.y*scaleY+Constants.WINDOW_HEIGHT/2-50;
		return point;
	}
	
	static final MathPoint toMathPoint(GraphPoint p){
		MathPoint point=new MathPoint();
		point.x=p.x-Constants.WINDOW_WIDTH/2;
		point.y=-p.y+Constants.WINDOW_HEIGHT/2-50;
		return point;
	}
	
	static final MathPoint toMathPoint(GraphPoint p,float scaleX,float scaleY){
		MathPoint point=new MathPoint();
		point.x=(p.x-Constants.WINDOW_WIDTH/2)*scaleX;
		point.y=(-p.y+Constants.WINDOW_HEIGHT/2-50)/scaleY;
		return point;
	}
}
